#include "../include/vertex.h"
#include "../my/include/Matrix.h"
#include <math.h>

Vertex::Vertex()
{
  x = 0.0;
  y = 0.0;
  z = 0.0;
  w = 0.0;
}

void Vertex::set(double px, double py, double pz, double pw)
{
  x = px;
  y = py;
  z = pz;
  w = pw;
}


void Vertex::multiply (const Matrix& mat) {
	double newx,newy,newz;
	newx = mat.m[0][0] * x + mat.m[0][1] * y + mat.m[0][2] * z + mat.m[0][3];
	newy = mat.m[1][0] * x + mat.m[1][1] * y + mat.m[1][2] * z + mat.m[1][3];
	newz = mat.m[2][0] * x + mat.m[2][1] * y + mat.m[2][2] * z + mat.m[2][3];
	x=newx;y=newy;z=newz;
}

Vector Vertex::operator- (const Vertex& vertex){
	Vector v= Vector();
	v.set(x - vertex.x , y - vertex.y , z - vertex.z);
	return v;
}

Vector Vertex::getVector(){
	Vector v= Vector();
	v.set(x,y,z);
	return v;
}
Vertex Vertex::operator+ (double b){
	Vertex returnVar = Vertex();
	returnVar.set(this->x+b,this->y+b,this->z+b,this->w);
	return returnVar;

}

double Vertex::distance (const Vertex& vertex){
	double deltax = x - vertex.x;
	double deltay = y - vertex.y;
	double deltaz = z - vertex.z;
	double distance = sqrt((deltax*deltax)+(deltay*deltay)+(deltaz*deltaz));
	return distance;
}
